Skip to content

fix: recalculate rowHeight() when isVirualized #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

jcalebj
Copy link

@jcalebj jcalebj commented Mar 8, 2018

When rendering rows with isVirualized, if rowHeight is a func, the
virtualized list was not recalculating the rowHeight.
Per the react-virtualized docs
here, List.recomputeRowHeights()
needs to be called.

This only fixes the dynamic rowHeight issue after dragging a node is
finished. An additional List.recomputeRowHeights() will need to be
called to fix the ‘preview’ while dragging a row (see issue below for
more details).

This partially fixes Issue 264.

When rendering rows with isVirualized, if rowHeight is a func, the
virtualized list was not recalculating the rowHeight.
Per the `react-virtualized` docs
[here](https://github.com/bvaughn/react-virtualized/blob/master/docs/Lis
t.md#recomputerowheights-index-number), `List.recomputeRowHeights()`
needs to be called.

This only fixes the dynamic rowHeight issue _after_ dragging a node is
finished.  An additional `List.recomputeRowHeights()` will need to be
called to fix the ‘preview’ while dragging a row (see issue below for
more details).

This partially fixes [Issue
264](frontend-collective#264).
@coveralls
Copy link

coveralls commented Mar 8, 2018

Pull Request Test Coverage Report for Build 184

  • 2 of 5 (40.0%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.1%) to 76.089%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/react-sortable-tree.js 2 5 40.0%
Files with Coverage Reduction New Missed Lines %
src/react-sortable-tree.js 1 75.67%
Totals Coverage Status
Change from base Build 175: -0.1%
Covered Lines: 589
Relevant Lines: 762

💛 - Coveralls

@@ -634,6 +636,9 @@ class ReactSortableTree extends Component {
{({ height, width }) => (
<ScrollZoneVirtualList
{...scrollToInfo}
ref={el => {
this.scrollZoneVirtualListComponent = el
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wuweiweiwu
Copy link
Member

wuweiweiwu commented Mar 9, 2018

@jcalebj This seems like a good idea. you can possible use the dragging state or the dragHover function to update the heights as well :)

Thus we wouldn't have to split up the fixes.

Also, it'll be nice if you can also write a test case for this :)

@jcalebj
Copy link
Author

jcalebj commented Mar 9, 2018

@wuweiweiwu On it 👍
Any input on fixing the last part (problem is detailed toward the end of the conversation on Issue 264) would be appreciated 🍻

@wuweiweiwu
Copy link
Member

@jcalebj you mean the rowHeight updating while dragging?

In that case I would checkout https://github.com/fritz-c/react-sortable-tree/blob/master/src/react-sortable-tree.js#L347

@jcalebj jcalebj force-pushed the jcalebj-fix/row-height-recalculation-is-virutalized branch from 394ab8b to 6c433d5 Compare March 12, 2018 17:53
@wuweiweiwu wuweiweiwu mentioned this pull request Mar 30, 2018
8 tasks
@jcalebj jcalebj closed this Apr 9, 2018
@jcalebj jcalebj deleted the jcalebj-fix/row-height-recalculation-is-virutalized branch April 9, 2018 21:35
@dcporter44
Copy link

dcporter44 commented Nov 6, 2018

Not sure why this was closed, this issue still exists. If isVirtualized is true and rowHeight is a function, the node heights do not change value even after dropped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rowHeight not refreshing while dragging
4 participants